package me.vbdetlevvb.plugins.bananasphere;

import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.lang.Math;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.generator.BlockPopulator;

public class BWorldGenerator extends ChunkGenerator {

	@Override
	public byte[] generate(World world, Random random, int cx, int zz) {
		byte[] result = new byte[16 * 16 * 128];

		for (int x2 = 0; x2 < 16; x2++) {
			for (int z2 = 0; z2 < 16; z2++) {
				int y;
				for (y = 0; y < 1; y++) {
					result[(x2 * 16 + z2) * 128 + y] = (byte) Material.BEDROCK.getId();
				}for(y = 1; y < 16; y++){
					result[(x2 * 16 + z2) * 128 + y] = (byte) Material.STONE.getId();
				}for(y = 16; y < 32; y++){
					result[(x2 * 16 + z2) * 128 + y ] = (byte) Material.DIRT.getId();
				}for(y = 32; y < 33; y++){ 
					result[(x2 * 16 + z2) * 128 + y ] = (byte) Material.GRASS.getId();
				}
			}
		}
		return result;
	}
	
    @Override
    public List<BlockPopulator> getDefaultPopulators(World world) {
    	//(BlockPopulator)new SpherePopulator(),
        return Arrays.asList((BlockPopulator)new HousePopulator());
    }
	@Override
    public boolean canSpawn(World world, int x, int z) {
        return true;
    }

    @Override
    public Location getFixedSpawnLocation(World world, Random random) {
        return new Location(world, 7, 77, 7);
    }

}